import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CombinationVO, CombinationForm, CombinationQuery } from '@/api/shopping/product/combination/types';

/**
 * 查询拼团产品列表
 * @param query
 * @returns {*}
 */

export const listCombination = (query?: CombinationQuery): AxiosPromise<CombinationVO[]> => {
  return request({
    url: '/shopping/combination/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询拼团产品详细
 * @param id
 */
export const getCombination = (id: string | number): AxiosPromise<CombinationVO> => {
  return request({
    url: '/shopping/combination/' + id,
    method: 'get'
  });
};

/**
 * 新增拼团产品
 * @param data
 */
export const addCombination = (data: CombinationForm) => {
  return request({
    url: '/shopping/combination',
    method: 'post',
    data: data
  });
};

/**
 * 修改拼团产品
 * @param data
 */
export const updateCombination = (data: CombinationForm) => {
  return request({
    url: '/shopping/combination',
    method: 'put',
    data: data
  });
};

/**
 * 删除拼团产品
 * @param id
 */
export const delCombination = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shopping/combination/' + id,
    method: 'delete'
  });
};
